package demo.gl;

import android.app.Activity;
import android.content.Intent;
import android.os.Bundle;
import android.view.Menu;
import android.view.MenuItem;

public class GameActivity extends Activity{
    /** Called when the activity is first created. */
	 OpenGLRenderer view;
	private static final int back = Menu.FIRST;
	private static final int auto = Menu.FIRST+1;
	private static final int help = Menu.FIRST+2;
	private static final int exit = Menu.FIRST+3;
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        view = new OpenGLRenderer(this);
        super.setContentView(view); 
    }
    @Override
    public boolean onCreateOptionsMenu(Menu menu) {
    	super.onCreateOptionsMenu(menu);
    	menu.add(0, back, 0, "Back").setIcon(R.drawable.back);
    	menu.add(1, auto, 0, "Auto").setIcon(R.drawable.auto);
    	menu.add(3, exit, 0, "Exit").setIcon(R.drawable.exit);
    	return super.onCreateOptionsMenu(menu);
    }
    public boolean onOptionsItemSelected(MenuItem item) {
    	switch (item.getItemId()) {
    	case back:
    	{
    		System.out.println("back");
    		Intent intentPlay=new Intent(GameActivity.this, GlActivity.class);
			startActivity(intentPlay);
			finish();
			break;
    	}
    	case auto:
    	{
    		if (OpenGLRenderer.isAutoplay==true)
    		{
    			OpenGLRenderer.isAutoplay=false;
    		}
    		else
    		{
    			OpenGLRenderer.isAutoplay=true;
    		}
    		break;
    	}
    	case exit:
    	{
    		finish();
    		break;
    	}
    	}
    	return true;
    }
}
